package com.udaos.modules.resource.services;

import java.util.List;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;

import com.udaos.common.base.Service;
import com.udaos.models.region.Ud_region;
import com.udaos.models.resource.Ud_wx_resource;
import com.udaos.models.sys.Sys_user;
import com.udaos.modules.company.services.UdCompanyRegionService;

/**
 * @author mutaotao
 * @time 2017-03-28 16:22:06
 * 
 */
@IocBean(args = { "refer:dao" })
public class UdWxResourceService extends Service<Ud_wx_resource> {
	
	@Inject
	private UdCompanyRegionService companyRegionService;
	
	public UdWxResourceService(Dao dao) {
		super(dao);
	}
	
	/**
	 * 获取当前主体下开通的区域
	 * @return
	 */
	public List<Ud_region> getRegions() {
		Subject subject = SecurityUtils.getSubject();
		Sys_user user = (Sys_user) subject.getPrincipal();
		String company_id=user.getUnit().getCompany_id();
		return companyRegionService.findRegionById(company_id);
	}
}